package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 菜单控制类
 * @Author makun
 * @Date 2023/10/20 14:44
 * @Version 1.0
 */
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    /**
     * 查询菜单
     * @param queryString
     * @return
     */
    @GetMapping()
    public Result getMenu(String queryString) {
        return Result.buildSuccess(menuService.getMenus(queryString));
    }

    /**
     * 以树结构获取所有的菜单
     * @return
     */
    @GetMapping("/asTree")
    public Result allMenusToTree() {
        return Result.buildSuccess(menuService.getAllMenusAsTree());
    }
}
